module.exports = {
  // publicPath: "",
  filenameHashing: true,
  productionSourceMap: true,
  // 处理IE兼容————vuex持久化脚本语法转译
  // transpileDependencies: ['vuex-persist', 'flatted', '@cloudpivot/*'],
  configureWebpack: (config) => {
    if (process.env.NODE_ENV === "production") {
      config.devtool = "source-map";
    } else {
      config.devtool = "cheap-eval-source-map";
    }
  },
  chainWebpack: (config) => {
    config.plugin("html").tap((args) => {
      args[0].title = "全过程工程咨询服务云平台";
      return args;
    });
  },
  devServer: {
    port: 9100,
    open: true,
    proxy: {
      "/prod-api/": {
        target: process.env.VUE_APP_API + "/",
        changeOrigin: true
      }
    },
    before: (app) => {
      /**
       * 支持跨域访问
       */
      app.all("*", function(req, res, next) {
        res.header("Access-Control-Allow-Origin", "*");
        res.header("Access-Control-Allow-Headers", "X-Requested-With");
        res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
        res.header("X-Powered-By", "3.2.1");
        if (req.method == "OPTIONS") {
          res.sendStatus(200);
        } else {
          next();
        }
      });
    },
    disableHostCheck: true
  },
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
        // prependData: `@import "~@/assets/style/main.less";`
      }
    }
  }
};
